/*
 * Copyright (C) 2021 The Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.oushangfeng.pinneddemo.custom.data;

import com.oushangfeng.pinneddemo.custom.categorylist.HeadItem;
import com.oushangfeng.pinneddemo.model.CommonViewModel;
import com.oushangfeng.pinneddemo.model.GridLayoutModel;
import com.oushangfeng.pinneddemo.model.LevelModel;

import ohos.app.Context;

import java.util.ArrayList;
import java.util.List;

/**
 * GridLayoutData
 *
 * @since 2021-03-27
 * Created by oubowu on 2021/3/27 10:29
 */
public class GridLayoutData {
    private static final int INT_10 = 10;
    private static final int INT_9 = 9;
    private ConstantData constantData = new ConstantData();
    Context context;

    /**
     * GridLayoutData
     *
     * @param context
     */
    public GridLayoutData(Context context) {
        this.context = context;
    }

    /**
     * getData
     *
     * @return List
     */
    public List getData() {
        List list = new ArrayList();
        int number = 0;

        // 一级list：竖
        for (int i = 0; i < constantData.PIC_ANI.length; i++) {
            list.add(new LevelModel(constantData.PIC_TITLE[i], HeadItem.ITEM_TYPE));
            number = INT_10 * i;

            // 二级list：竖
            list.add(gridLayoutModel(constantData.PIC_TITLE[i], number, constantData.PIC_ANI[i]));
        }
        return list;
    }

    GridLayoutModel gridLayoutModel(String name, int number, int[] imgIdArray) {
        List list = new ArrayList();
        for (int j = 0; j < INT_9; j++) {
            number++;
            list.add(new CommonViewModel(context, 1, number + "", imgIdArray[j], name));
        }
        return new GridLayoutModel("", list);
    }
}
